package com.hr.service.impl;

import com.github.pagehelper.PageHelper;
import com.hr.mapper.ProductMapper;
import com.hr.pojo.Product;
import com.hr.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class ProductServiceImpl implements ProductService{
    @Autowired
    private ProductMapper productMapper;

    @Override
    public List<Product> getProductList() {
        //PageHelper.startPage 只能影响之后的第一条查询语句
        PageHelper.startPage(2,4,"pid");
        List<Product> products = productMapper.selectAll();
        return products;
    }

    @Override
    @Transactional
    public int insert(Product product) {
        return productMapper.insert(product);
    }
}
